package com.sunkyc.framework.system.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface MenuMapper {


    /**
     * 根据角色id查询权限标识集合
     * @param roleId
     * @return
     */
    @Select("select sm.perms from sys_role_menu as rm\n" +
            "left join sys_menu as sm\n" +
            "on rm.menu_id = sm.menu_id\n" +
            "where sm.perms is not null and rm.role_id = #{roleId}")
    List<String> queryMenuPeremsByRoleId(@Param("roleId") Long roleId);

    /**
     * 根据角色id查询菜单id
     */
    @Select("select sm.menu_id from sys_role_menu as rm\n" +
            "left join sys_menu as sm\n" +
            "on rm.menu_id = sm.menu_id\n" +
            "where rm.role_id = #{roleId}")
    List<Long> queryMenuIdsByRoleId(@Param("roleId") Long roleId);




}
